package com.rzjm.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.rzjm.api.dao.ChargerPortMapper;
import com.rzjm.api.entity.Charger;
import com.rzjm.api.entity.ChargerPort;
import com.rzjm.api.service.ChargerPortService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 充电设备端口 Service业务层处理
 *
 * @author ruoyi
 * @date 2022-05-07
 */
@Service
public class ChargerPortServiceImpl extends BaseServiceImpl<ChargerPortMapper, ChargerPort> implements ChargerPortService {

    @Resource
    private ChargerPortMapper chargerPortMapper;

    @Override
    public ChargerPort getPortByChargerAndPort(Charger charger, int port) {
        QueryWrapper<ChargerPort> qw = new QueryWrapper<>();
        qw.eq("charger_id",charger.getId());
        qw.eq("port_index",port);
        qw.last("limit 1");
        return chargerPortMapper.selectOne(qw);
    }


    @Override
    public ChargerPort getPortByChargerIdAndPort(int chargerId, int port) {
        QueryWrapper<ChargerPort> qw = new QueryWrapper<>();
        qw.eq("charger_id",chargerId);
        qw.eq("port_index",port);
        qw.last("limit 1");
        return chargerPortMapper.selectOne(qw);
    }


}
